package com.yunkeji.api.feedback.controller;

import com.yunkeji.api.feedback.bo.SubmitFeedbackBo;
import com.yunkeji.api.feedback.service.FeedbackService;
import com.yunkeji.common.annotation.RepeatSubmit;
import com.yunkeji.common.core.controller.BaseController;
import com.yunkeji.common.core.domain.R;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.concurrent.TimeUnit;

/**
 * 用户反馈
 *
 * @author 老张
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/v1/feedback")
public class FeedbackController extends BaseController {

    private final FeedbackService feedbackService;

    /** 提交反馈 */
    @PostMapping("/submit")
    @RepeatSubmit(interval = 1, timeUnit = TimeUnit.HOURS, message = "您近期已经提交了反馈")
    public R submit(@Valid @RequestBody SubmitFeedbackBo bo) {
        feedbackService.submit(bo);
        return R.ok();
    }

}
